﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Lost_and_Found.Models.DB;

namespace Lost_and_Found.Models.ViewModel
{
    public class TopicPage
    {
        public int PageId { get; set; }
        public int TopicCount { get; set; }
        public List<TopicModel> Topics { get; set; }
        public int PageSize { get; set; }
    }
    public class TopicModel
    {

        public string TimePost;

        public string Content;
        public string Title;
        public string Type;
        public string UserPost;
        public int ID;
        public string Location;
        public string Time;

        public TopicModel(Topic topic)
        {
            this.ID = topic.TopicID;
            this.UserPost = topic.User.Username;
            this.TimePost = topic.DatePost.ToShortTimeString() + " ngày " + topic.DatePost.Day + "/" + topic.DatePost.Month + "/" + topic.DatePost.Year;
            this.Time = topic.Date.Day + "/" + topic.Date.Month + "/" + topic.Date.Year;
            this.Title = topic.Title;
            this.Location = topic.Location;
            this.Type = topic.Type;
            string x= (this.Type.Equals("Lost"))?("Tôi có đánh rơi : "):("Tôi có nhặt được : ");
            foreach (var item in topic.Items)
            {
                x +=  item.Name;
                if (item != topic.Items.Last())
                {
                    x += " , ";
                }
            }
            this.Content = x;

        }
    }

}